#include <iostream>
#include <string>
using namespace std;
string pushDominoes(string dominoes)
{
	int sz = dominoes.length();
	int i = 0;
	char left = 'L';
	while (i < sz)
	{
		int j = i;
		while (j < sz && dominoes[j] == '.')
		{
			j++;
		}
		char right = j < sz ? dominoes[j] : 'R';
		if (left == right)
		{
			while (i < j)
			{
				dominoes[i++] = right;
			}
		}
		else if(left=='R'&&right=='L')
		{
			int k = j - 1;
			while (i < k)
			{
				dominoes[i++] = 'R';
				dominoes[k--] = 'L';
			}
		}
		left = right;
		i = j + 1;
	}
	return dominoes;
}
int main()
{
	char ch[] = "RR.L";
	string chr=pushDominoes(ch);
	cout << chr << endl;
	system("pause");
	return 0;
}